package com.sunda.spmswms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.sunda.spmswms.entity.SapBoxNoteDtl;
import com.sunda.spmswms.mapper.SapBoxNoteDtlMapper;
import com.sunda.spmswms.service.ISapBoxNoteDtlService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 箱码行项目表 服务实现类
 * </p>
 *
 * @author Wayne
 * @since 2021-03-29
 */
@Service
public class SapBoxNoteDtlServiceImpl extends ServiceImpl<SapBoxNoteDtlMapper, SapBoxNoteDtl> implements ISapBoxNoteDtlService {

    @Autowired
    SapBoxNoteDtlMapper sapBoxNoteDtlMapper;

    /** 根据箱码将箱码明细表中的 国内收货数量（箱码）、国内实际数量（箱内各物料的实际数量） */
    @Override
    public void updateSapBoxNoteDtl(String boxNote, double boxNoteQty) {
        this.baseMapper.updateSapBoxNoteDtl(boxNote, boxNoteQty);
    }


    @Override
    public void updateSapBoxNoteDtlBeta(String boxNote, int item, Double domesticQtyReceived, String remarks) {
        sapBoxNoteDtlMapper.updateSapBoxNoteDtlBeta(boxNote, item, domesticQtyReceived, remarks);
    }

    @Override
    public List<SapBoxNoteDtl> getBoxNoteDtlList(String boxNote, String item) {
        if (StringUtils.isEmpty(boxNote) || StringUtils.isEmpty(item)){
            return null;
        }
        return this.baseMapper.selectList(new QueryWrapper<SapBoxNoteDtl>().eq("BOX_NOTE", boxNote).eq("ITEM", item));
    }

    @Override
    public List<SapBoxNoteDtl> getSapBoxNoteDtlList(String boxNote) {
        if (StringUtils.isEmpty(boxNote)){
            return null;
        }
        return this.baseMapper.selectList(new QueryWrapper<SapBoxNoteDtl>().eq("BOX_NOTE", boxNote));
    }
}
